Skip to contentSkip to conversation

Make bootable rpi4b model

PATCH In review Sergey Kambalin 4 participants 9 messages May 22, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Make bootable rpi4b model

---
 configs/devices/aarch64-softmmu/default.mak |   2 +
 hw/arm/Kconfig                              |   7 +
 hw/arm/bcm2835_peripherals.c                | 223 ++++++-----
 hw/arm/bcm2836.c                            | 129 ++++---
 hw/arm/bcm2838.c                            | 283 ++++++++++++++
 hw/arm/bcm2838_peripherals.c                | 213 +++++++++++
 hw/arm/meson.build                          |   5 +
 hw/arm/raspi.c                              | 129 ++++---
 hw/arm/raspi4b.c                            | 243 ++++++++++++
 hw/arm/trace-events                         |   2 +
 hw/gpio/bcm2838_gpio.c                      | 395 ++++++++++++++++++++
 hw/gpio/meson.build                         |   1 +
 hw/misc/bcm2835_powermgt.c                  |  37 ++
 hw/misc/bcm2835_property.c                  | 318 +++++++++++++---
 hw/misc/trace-events                        |  10 +
 include/hw/arm/bcm2835_peripherals.h        |  29 +-
 include/hw/arm/bcm2836.h                    |  30 +-
 include/hw/arm/bcm2838.h                    |  26 ++
 include/hw/arm/bcm2838_peripherals.h        |  50 +++
 include/hw/arm/raspi4b_platform.h           |  58 +++
 include/hw/arm/raspi_platform.h             |  34 ++
 include/hw/display/bcm2835_fb.h             |   2 +
 include/hw/gpio/bcm2838_gpio.h              |  45 +++
 include/hw/misc/bcm2835_powermgt.h          |   2 +-
 include/hw/misc/raspberrypi-fw-defs.h       | 169 +++++++++
 tests/avocado/boot_linux_console.py         |  37 ++
 26 files changed, 2210 insertions(+), 269 deletions(-)
 create mode 100644 hw/arm/bcm2838.c
 create mode 100644 hw/arm/bcm2838_peripherals.c
 create mode 100644 hw/arm/raspi4b.c
 create mode 100644 hw/gpio/bcm2838_gpio.c
 create mode 100644 include/hw/arm/bcm2838.h
 create mode 100644 include/hw/arm/bcm2838_peripherals.h
 create mode 100644 include/hw/arm/raspi4b_platform.h
 create mode 100644 include/hw/gpio/bcm2838_gpio.h
 create mode 100644 include/hw/misc/raspberrypi-fw-defs.h
configs/devices/aarch64-softmmu/default.mak +2 -0
index 70e05a197d..3d249ceef5 100644
@@ -2,3 +2,5 @@
 
 # We support all the 32 bit boards so need all their config
 include ../arm-softmmu/default.mak
+
+CONFIG_RASPI4B=y
hw/arm/Kconfig +7 -0
index 0f42c556d7..6ea33abc01 100644
@@ -382,6 +382,13 @@ config RASPI
     select SDHCI
     select USB_DWC2
 
+config RASPI4B
+    bool
+    select FRAMEBUFFER
+    select PL011 # UART
+    select SDHCI
+    select USB_DWC2
+
 config STM32F100_SOC
     bool
     select ARM_V7M
hw/arm/bcm2835_peripherals.c +135 -88

321 lines not on this page · raw message

hw/arm/bcm2836.c +67 -62

244 lines not on this page · raw message

hw/arm/bcm2838.c new file +283 -0

283 lines not on this page · raw message

hw/arm/bcm2838_peripherals.c new file +213 -0

213 lines not on this page · raw message

hw/arm/meson.build +5 -0
index b545ba0e4f..e49291effb 100644
@@ -38,6 +38,10 @@ arm_ss.add(when: 'CONFIG_STRONGARM', if_true: files('strongarm.c'))
 arm_ss.add(when: 'CONFIG_ALLWINNER_A10', if_true: files('allwinner-a10.c', 'cubieboard.c'))
 arm_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3.c', 'orangepi.c'))
 arm_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2836.c', 'raspi.c'))
+arm_ss.add(when: 'CONFIG_RASPI4B', if_true: files(
+  'bcm2838.c',
+  'raspi4b.c'
+))
 arm_ss.add(when: 'CONFIG_STM32F100_SOC', if_true: files('stm32f100_soc.c'))
 arm_ss.add(when: 'CONFIG_STM32F205_SOC', if_true: files('stm32f205_soc.c'))
 arm_ss.add(when: 'CONFIG_STM32F405_SOC', if_true: files('stm32f405_soc.c'))
@@ -66,6 +70,7 @@ arm_ss.add(when: 'CONFIG_NRF51_SOC', if_true: files('nrf51_soc.c'))
 softmmu_ss.add(when: 'CONFIG_ARM_SMMUV3', if_true: files('smmu-common.c'))
 softmmu_ss.add(when: 'CONFIG_EXYNOS4', if_true: files('exynos4_boards.c'))
 softmmu_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2835_peripherals.c'))
+softmmu_ss.add(when: 'CONFIG_RASPI4B', if_true: files('bcm2838_peripherals.c'))
 softmmu_ss.add(when: 'CONFIG_TOSA', if_true: files('tosa.c'))
 
 hw_arch += {'arm': arm_ss}
hw/arm/raspi.c +75 -54

261 lines not on this page · raw message

hw/arm/raspi4b.c new file +243 -0

243 lines not on this page · raw message

hw/arm/trace-events +2 -0
index 2dee296c8f..91c0948f63 100644
@@ -53,3 +53,5 @@ smmuv3_notify_flag_add(const char *iommu) "ADD SMMUNotifier node for iommu mr=%s
 smmuv3_notify_flag_del(const char *iommu) "DEL SMMUNotifier node for iommu mr=%s"
 smmuv3_inv_notifiers_iova(const char *name, uint16_t asid, uint64_t iova, uint8_t tg, uint64_t num_pages) "iommu mr=%s asid=%d iova=0x%"PRIx64" tg=%d num_pages=0x%"PRIx64
 
+# bcm2838.c
+bcm2838_gic_set_irq(int irq, int level) "gic irq:%d lvl:%d"
hw/gpio/bcm2838_gpio.c new file +395 -0

395 lines not on this page · raw message

hw/gpio/meson.build +1 -0
index b726e6d27a..c1dc2bdd06 100644
@@ -10,5 +10,6 @@ softmmu_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx_gpio.c'))
 softmmu_ss.add(when: 'CONFIG_NRF51_SOC', if_true: files('nrf51_gpio.c'))
 softmmu_ss.add(when: 'CONFIG_OMAP', if_true: files('omap_gpio.c'))
 softmmu_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2835_gpio.c'))
+softmmu_ss.add(when: 'CONFIG_RASPI4B', if_true: files('bcm2838_gpio.c'))
 softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_gpio.c'))
 softmmu_ss.add(when: 'CONFIG_SIFIVE_GPIO', if_true: files('sifive_gpio.c'))
hw/misc/bcm2835_powermgt.c +37 -0
index 976f3d34e5..a249683471 100644
@@ -23,6 +23,8 @@
 #define R_RSTS 0x20
 #define V_RSTS_POWEROFF 0x555 /* Linux uses partition 63 to indicate halt. */
 #define R_WDOG 0x24
+#define R_ASB 0x20
+#define BCM2835_BRDG_ID 0x62726467
 
 static uint64_t bcm2835_powermgt_read(void *opaque, hwaddr offset,
                                       unsigned size)
@@ -97,6 +99,29 @@ static void bcm2835_powermgt_write(void *opaque, hwaddr offset,
     }
 }
 
+static uint64_t bcm2835_asb_read(void *opaque, hwaddr offset,
+                                      unsigned size)
+{
+    uint32_t res = 0;
+
+    switch (offset) {
+    case R_ASB:
+        qemu_log("Attempt to read PM BCM2835_BRDG_ID");
+        res = BCM2835_BRDG_ID;
+        break;
+
+    default:
+        qemu_log_mask(LOG_UNIMP,
+                      "bcm2835_asb_read: Unknown offset 0x%08"HWADDR_PRIx
+                      "\n", offset);
+        res = 0;
+        break;
+    }
+
+    return res;
+}
+
+
 static const MemoryRegionOps bcm2835_powermgt_ops = {
     .read = bcm2835_powermgt_read,
     .write = bcm2835_powermgt_write,
@@ -105,6 +130,13 @@ static const MemoryRegionOps bcm2835_powermgt_ops = {
     .impl.max_access_size = 4,
 };
 
+static const MemoryRegionOps bcm2835_asb_ops = {
+    .read = bcm2835_asb_read,
+    .endianness = DEVICE_NATIVE_ENDIAN,
+    .impl.min_access_size = 4,
+    .impl.max_access_size = 4,
+};
+
 static const VMStateDescription vmstate_bcm2835_powermgt = {
     .name = TYPE_BCM2835_POWERMGT,
     .version_id = 1,
@@ -124,6 +156,11 @@ static void bcm2835_powermgt_init(Object *obj)
     memory_region_init_io(&s->iomem, obj, &bcm2835_powermgt_ops, s,
                           TYPE_BCM2835_POWERMGT, 0x200);
     sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->iomem);
+
+    /* See bcm2835-common.dtsi */
+    memory_region_init_io(&s->iomem_asb, obj, &bcm2835_asb_ops, s,
+                          TYPE_BCM2835_POWERMGT, 0x24);
+    sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->iomem_asb);
 }
 
 static void bcm2835_powermgt_reset(DeviceState *dev)
hw/misc/bcm2835_property.c +262 -56

505 lines not on this page · raw message

hw/misc/trace-events +10 -0
index c47876a902..13ecd6f5fd 100644
@@ -279,3 +279,13 @@ virt_ctrl_instance_init(void *dev) "ctrl: %p"
 lasi_chip_mem_valid(uint64_t addr, uint32_t val) "access to addr 0x%"PRIx64" is %d"
 lasi_chip_read(uint64_t addr, uint32_t val) "addr 0x%"PRIx64" val 0x%08x"
 lasi_chip_write(uint64_t addr, uint32_t val) "addr 0x%"PRIx64" val 0x%08x"
+
+# bcm2838_rng200.c
+bcm2838_rng200_rng_soft_reset(void) "========= RNumG SOFT RESET ========="
+bcm2838_rng200_rbg_soft_reset(void) "========= RBitG SOFT RESET ========="
+bcm2838_rng200_enable_rbg(void)     "========= RBitG ENABLED ========="
+bcm2838_rng200_disable_rbg(void)    "========= RBitG DISABLED ========="
+bcm2838_rng200_update_fifo(uint32_t len, uint32_t fifo_len)    "len %u, fifo_len %u"
+bcm2838_rng200_fifo_full(void) "========= RNumG FIFO FULL ========="
+bcm2838_rng200_write(void *addr, uint64_t value, unsigned size) "addr %p, value 0x%016" PRIx64 ", size %u"
+bcm2838_rng200_read(void *addr, unsigned size, uint64_t value) "addr %p, size %u, value 0x%016" PRIx64
include/hw/arm/bcm2835_peripherals.h +25 -4
index d724a2fc28..dec61e2fd8 100644
@@ -34,10 +34,13 @@
 #include "hw/misc/unimp.h"
 #include "qom/object.h"
 
+#define TYPE_RASPI_PERIPHERALS_BASE "raspi-peripherals-base"
+OBJECT_DECLARE_TYPE(RaspiPeripheralBaseState, RaspiPeripheralBaseClass,
+                    RASPI_PERIPHERALS_BASE)
 #define TYPE_BCM2835_PERIPHERALS "bcm2835-peripherals"
 OBJECT_DECLARE_SIMPLE_TYPE(BCM2835PeripheralState, BCM2835_PERIPHERALS)
 
-struct BCM2835PeripheralState {
+struct RaspiPeripheralBaseState {
     /*< private >*/
     SysBusDevice parent_obj;
     /*< public >*/
@@ -59,12 +62,9 @@ struct BCM2835PeripheralState {
     OrIRQState orgated_dma_irq;
     BCM2835ICState ic;
     BCM2835PropertyState property;
-    BCM2835RngState rng;
     BCM2835MboxState mboxes;
     SDHCIState sdhci;
     BCM2835SDHostState sdhost;
-    BCM2835GpioState gpio;
-    Bcm2835ThermalState thermal;
     UnimplementedDeviceState i2s;
     UnimplementedDeviceState spi[1];
     UnimplementedDeviceState i2c[3];
@@ -78,4 +78,25 @@ struct BCM2835PeripheralState {
     UnimplementedDeviceState sdramc;
 };
 
+struct RaspiPeripheralBaseClass {
+    /*< private >*/
+    SysBusDeviceClass parent_class;
+    /*< public >*/
+    uint64_t peri_size; /* Peripheral range size */
+};
+
+struct BCM2835PeripheralState {
+    /*< private >*/
+    RaspiPeripheralBaseState parent_obj;
+    /*< public >*/
+    BCM2835RngState rng;
+    Bcm2835ThermalState thermal;
+    BCM2835GpioState gpio;
+};
+
+void create_unimp(RaspiPeripheralBaseState *ps,
+                  UnimplementedDeviceState *uds,
+                  const char *name, hwaddr ofs, hwaddr size);
+void raspi_peripherals_common_realize(DeviceState *dev, Error **errp);
+
 #endif /* BCM2835_PERIPHERALS_H */
include/hw/arm/bcm2836.h +26 -4
index 6f90cabfa3..de6fe3ba0b 100644
@@ -17,8 +17,10 @@
 #include "target/arm/cpu.h"
 #include "qom/object.h"
 
+#define TYPE_BCM283X_BASE "bcm283x-base"
+OBJECT_DECLARE_TYPE(BCM283XBaseState, BCM283XBaseClass, BCM283X_BASE)
 #define TYPE_BCM283X "bcm283x"
-OBJECT_DECLARE_TYPE(BCM283XState, BCM283XClass, BCM283X)
+OBJECT_DECLARE_SIMPLE_TYPE(BCM283XState, BCM283X)
 
 #define BCM283X_NCPUS 4
 
@@ -29,19 +31,39 @@ OBJECT_DECLARE_TYPE(BCM283XState, BCM283XClass, BCM283X)
 #define TYPE_BCM2835 "bcm2835"
 #define TYPE_BCM2836 "bcm2836"
 #define TYPE_BCM2837 "bcm2837"
+#define TYPE_BCM2838 "bcm2838"
 
-struct BCM283XState {
+struct BCM283XBaseState {
     /*< private >*/
     DeviceState parent_obj;
     /*< public >*/
-
     uint32_t enabled_cpus;
-
     struct {
         ARMCPU core;
     } cpu[BCM283X_NCPUS];
     BCM2836ControlState control;
+};
+
+struct BCM283XBaseClass {
+    /*< private >*/
+    DeviceClass parent_class;
+    /*< public >*/
+    const char *name;
+    const char *cpu_type;
+    unsigned core_count;
+    hwaddr peri_base; /* Peripheral base address seen by the CPU */
+    hwaddr ctrl_base; /* Interrupt controller and mailboxes etc. */
+    int clusterid;
+};
+
+struct BCM283XState {
+    /*< private >*/
+    BCM283XBaseState parent_obj;
+    /*< public >*/
     BCM2835PeripheralState peripherals;
 };
 
+bool bcm283x_common_realize(DeviceState *dev, RaspiPeripheralBaseState *ps,
+                            Error **errp);
+
 #endif /* BCM2836_H */
include/hw/arm/bcm2838.h new file +26 -0
new file mode 100644
index 0000000000..685fbcc5a2
@@ -0,0 +1,26 @@
+/*
+ * BCM2838 SoC emulation
+ *
+ * Copyright (C) 2022 Ovchinnikov Vitalii <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef BCM2838_H
+#define BCM2838_H
+
+#include "hw/arm/bcm2836.h"
+#include "hw/intc/arm_gic.h"
+#include "hw/arm/bcm2838_peripherals.h"
+
+OBJECT_DECLARE_TYPE(BCM2838State, BCM2838Class, BCM2838)
+
+struct BCM2838State {
+    /*< private >*/
+    BCM283XBaseState parent_obj;
+    /*< public >*/
+    BCM2838PeripheralState peripherals;
+    GICState gic;
+};
+
+#endif /* BCM2838_H */
include/hw/arm/bcm2838_peripherals.h new file +50 -0

50 lines not on this page · raw message

include/hw/arm/raspi4b_platform.h new file +58 -0

58 lines not on this page · raw message

include/hw/arm/raspi_platform.h +34 -0
index 4a56dd4b89..681b9633a1 100644
@@ -28,6 +28,35 @@
 #ifndef HW_ARM_RASPI_PLATFORM_H
 #define HW_ARM_RASPI_PLATFORM_H
 
+#include "hw/boards.h"
+#include "hw/arm/boot.h"
+
+#define TYPE_RASPI_BASE_MACHINE MACHINE_TYPE_NAME("raspi-base")
+OBJECT_DECLARE_TYPE(RaspiBaseMachineState, RaspiBaseMachineClass,
+                    RASPI_BASE_MACHINE)
+
+struct RaspiBaseMachineState {
+    /*< private >*/
+    MachineState parent_obj;
+    /*< public >*/
+    struct arm_boot_info binfo;
+};
+
+struct RaspiBaseMachineClass {
+    /*< private >*/
+    MachineClass parent_obj;
+    /*< public >*/
+    uint32_t board_rev;
+};
+
+uint64_t board_ram_size(uint32_t board_rev);
+const char *board_soc_type(uint32_t board_rev);
+void raspi_machine_class_common_init(MachineClass *mc,
+                                     uint32_t board_rev);
+typedef struct BCM283XBaseState BCM283XBaseState;
+void raspi_base_machine_init(MachineState *machine,
+                             BCM283XBaseState *soc);
+
 #define MSYNC_OFFSET            0x0000   /* Multicore Sync Block */
 #define CCPT_OFFSET             0x1000   /* Compact Camera Port 2 TX */
 #define INTE_OFFSET             0x2000   /* VC Interrupt controller */
@@ -170,4 +199,9 @@
 #define INTERRUPT_ILLEGAL_TYPE0        6
 #define INTERRUPT_ILLEGAL_TYPE1        7
 
+#define RPI_FIRMWARE_EMMC_CLK_RATE    50000000
+#define RPI_FIRMWARE_UART_CLK_RATE    3000000
+#define RPI_FIRMWARE_CORE_CLK_RATE    350000000
+#define RPI_FIRMWARE_DEFAULT_CLK_RATE 700000000
+
 #endif
include/hw/display/bcm2835_fb.h +2 -0
index 38671afffd..49541bf08f 100644
@@ -16,6 +16,8 @@
 #include "ui/console.h"
 #include "qom/object.h"
 
+#define UPPER_RAM_BASE 0x40000000
+
 #define TYPE_BCM2835_FB "bcm2835-fb"
 OBJECT_DECLARE_SIMPLE_TYPE(BCM2835FBState, BCM2835_FB)
 
include/hw/gpio/bcm2838_gpio.h new file +45 -0

45 lines not on this page · raw message

include/hw/misc/bcm2835_powermgt.h +1 -1
index 303b9a6f68..37b7c30de0 100644
@@ -19,7 +19,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(BCM2835PowerMgtState, BCM2835_POWERMGT)
 
 struct BCM2835PowerMgtState {
     SysBusDevice busdev;
-    MemoryRegion iomem;
+    MemoryRegion iomem, iomem_asb;
 
     uint32_t rstc;
     uint32_t rsts;
include/hw/misc/raspberrypi-fw-defs.h new file +169 -0

72 lines not on this page · raw message

tests/avocado/boot_linux_console.py +37 -0
index c0675809e6..7e5b8d034b 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.34.1

Part of the diff is not shown here. View the raw message.

#1 lore raw
Quoted 22 lines · Sergey Kambalin
---
 configs/devices/aarch64-softmmu/default.mak |   2 +
 hw/arm/Kconfig                              |   7 +
 hw/arm/bcm2835_peripherals.c                | 223 ++++++-----
 hw/arm/bcm2836.c                            | 129 ++++---
 hw/arm/bcm2838.c                            | 283 ++++++++++++++
 hw/arm/bcm2838_peripherals.c                | 213 +++++++++++
 hw/arm/meson.build                          |   5 +
 hw/arm/raspi.c                              | 129 ++++---
 hw/arm/raspi4b.c                            | 243 ++++++++++++
 hw/arm/trace-events                         |   2 +
 hw/gpio/bcm2838_gpio.c                      | 395 ++++++++++++++++++++
 hw/gpio/meson.build                         |   1 +
 hw/misc/bcm2835_powermgt.c                  |  37 ++
 hw/misc/bcm2835_property.c                  | 318 +++++++++++++---
 hw/misc/trace-events                        |  10 +
 include/hw/arm/bcm2835_peripherals.h        |  29 +-
 include/hw/arm/bcm2836.h                    |  30 +-
 include/hw/arm/bcm2838.h                    |  26 ++
 include/hw/arm/bcm2838_peripherals.h        |  50 +++
Quoted 8 lines
 include/hw/arm/raspi4b_platform.h           |  58 +++
 include/hw/arm/raspi_platform.h             |  34 ++
 include/hw/display/bcm2835_fb.h             |   2 +
 include/hw/gpio/bcm2838_gpio.h              |  45 +++
 include/hw/misc/bcm2835_powermgt.h          |   2 +-
 include/hw/misc/raspberrypi-fw-defs.h       | 169 +++++++++
 tests/avocado/boot_linux_console.py         |  37 ++
 26 files changed, 2210 insertions(+), 269 deletions(-)

Hi; this is far too large to be reviewable as a single patch. It must be split into more digestible chunks (each of which does a single reasonably coherent thing) before we can do anything with it.

thanks
-- PMM

#2 lore raw

Hi!

Unfortunately it can't be split without losing a functionality. It is a minimal amount of code to make it able to boot the kernel (and therefore confirm that it works).

________________________________
От: Peter Maydell <[email protected]>
Отправлено: 22 мая 2023 г. 13:32:52
Кому: Sergey Kambalin
Копия: [email protected]; [email protected]; Kambalin, Sergey Тема: Re: [PATCH] [rpi4b] Make bootable rpi4b model

Quoted 22 lines · Sergey Kambalin
---
 configs/devices/aarch64-softmmu/default.mak |   2 +
 hw/arm/Kconfig                              |   7 +
 hw/arm/bcm2835_peripherals.c                | 223 ++++++-----
 hw/arm/bcm2836.c                            | 129 ++++---
 hw/arm/bcm2838.c                            | 283 ++++++++++++++
 hw/arm/bcm2838_peripherals.c                | 213 +++++++++++
 hw/arm/meson.build                          |   5 +
 hw/arm/raspi.c                              | 129 ++++---
 hw/arm/raspi4b.c                            | 243 ++++++++++++
 hw/arm/trace-events                         |   2 +
 hw/gpio/bcm2838_gpio.c                      | 395 ++++++++++++++++++++
 hw/gpio/meson.build                         |   1 +
 hw/misc/bcm2835_powermgt.c                  |  37 ++
 hw/misc/bcm2835_property.c                  | 318 +++++++++++++---
 hw/misc/trace-events                        |  10 +
 include/hw/arm/bcm2835_peripherals.h        |  29 +-
 include/hw/arm/bcm2836.h                    |  30 +-
 include/hw/arm/bcm2838.h                    |  26 ++
 include/hw/arm/bcm2838_peripherals.h        |  50 +++
Quoted 8 lines
 include/hw/arm/raspi4b_platform.h           |  58 +++
 include/hw/arm/raspi_platform.h             |  34 ++
 include/hw/display/bcm2835_fb.h             |   2 +
 include/hw/gpio/bcm2838_gpio.h              |  45 +++
 include/hw/misc/bcm2835_powermgt.h          |   2 +-
 include/hw/misc/raspberrypi-fw-defs.h       | 169 +++++++++
 tests/avocado/boot_linux_console.py         |  37 ++
 26 files changed, 2210 insertions(+), 269 deletions(-)

Hi; this is far too large to be reviewable as a single patch. It must be split into more digestible chunks (each of which does a single reasonably coherent thing) before we can do anything with it.

thanks
-- PMM

#3 lore raw
Quoted 4 lines · Sergey

Hi!

Unfortunately it can't be split without losing a functionality. It is a minimal amount of code to make it able to boot the kernel (and therefore confirm that it works).

No, it absolutely can. Each individual patch should be a coherent chunk of work, and needs to compile cleanly, but it doesn't have to be immediately useful on its own. The usual setup is that a patchseries adding a new board gradually adds pieces like new devices or bugfixes to existing code, and it's only in a patch fairly late in the series that the new board proper is added and enabled.

In a 5 minute scan of this patch I saw at least one cleanup patch that should be separate (changing hard-coded numbers in the switch cases in the bcm2835_property.c file). Anything where you're touching the existing bcm2835/2836 code because you need to refactor it to be a better base for the bcm2838 work should be a separate patch (this is particularly important so we can review that the changes don't break the existing boards). And the usual approach with a new board is that you have a patch per new device being added (you have several here) and then a patch at the end for the board changes. New test cases can be their own patch. Documentation (which seems to be missing here) can be its own patch.

I would estimate that this will end up being at least 6 patches, probably more.

thanks
-- PMM

#4 lore raw

Aw, I thought the entire machine should work at the first patch.

Thank you for the detailed clarification! I think I've got the idea. I'll split it up.

Could you please tell me what size is appropriate for a single patch?

________________________________
От: Peter Maydell <[email protected]> Отправлено: 22 мая 2023 г. 13:58:42
Кому: Kambalin, Sergey
Копия: Sergey Kambalin; [email protected]; [email protected] Тема: Re: [PATCH] [rpi4b] Make bootable rpi4b model

Quoted 4 lines · Sergey

Hi!

Unfortunately it can't be split without losing a functionality. It is a minimal amount of code to make it able to boot the kernel (and therefore confirm that it works).

No, it absolutely can. Each individual patch should be a coherent chunk of work, and needs to compile cleanly, but it doesn't have to be immediately useful on its own. The usual setup is that a patchseries adding a new board gradually adds pieces like new devices or bugfixes to existing code, and it's only in a patch fairly late in the series that the new board proper is added and enabled.

In a 5 minute scan of this patch I saw at least one cleanup patch that should be separate (changing hard-coded numbers in the switch cases in the bcm2835_property.c file). Anything where you're touching the existing bcm2835/2836 code because you need to refactor it to be a better base for the bcm2838 work should be a separate patch (this is particularly important so we can review that the changes don't break the existing boards). And the usual approach with a new board is that you have a patch per new device being added (you have several here) and then a patch at the end for the board changes. New test cases can be their own patch. Documentation (which seems to be missing here) can be its own patch.

I would estimate that this will end up being at least 6 patches, probably more.

thanks
-- PMM

#5 lore raw
Quoted 6 lines · Sergey

Aw, I thought the entire machine should work at the first patch.

Thank you for the detailed clarification! I think I've got the idea. I'll split it up.

Could you please tell me what size is appropriate for a single patch?

The most important things for patch splitting are:
* everything still has to compile cleanly
* the contents of a single patch should be a coherent single thing that it makes sense to review in one part

If there's something in there that only touches 20 lines of code but is a coherent single change, it's fine to have that in its own patch -- small patches are easy to review.

At the upper end, I tend to think a patch is a bit big at around 200 lines, but for the specific case of "here is a new device" bigger than that is OK, because it's just adding new files rather than merging changes into existing ones.

https://www.qemu.org/docs/master/devel/submitting-a-patch.html
has some other advice on patch submission, if you haven't read that yet.

thanks
-- PMM

#6 lore raw

Thanks!

________________________________
От: Peter Maydell <[email protected]> Отправлено: 22 мая 2023 г. 15:01:26
Кому: Kambalin, Sergey
Копия: Sergey Kambalin; [email protected]; [email protected] Тема: Re: [PATCH] [rpi4b] Make bootable rpi4b model

Quoted 6 lines · Sergey

Aw, I thought the entire machine should work at the first patch.

Thank you for the detailed clarification! I think I've got the idea. I'll split it up.

Could you please tell me what size is appropriate for a single patch?

The most important things for patch splitting are:
* everything still has to compile cleanly
* the contents of a single patch should be a coherent single thing that it makes sense to review in one part

If there's something in there that only touches 20 lines of code but is a coherent single change, it's fine to have that in its own patch -- small patches are easy to review.

At the upper end, I tend to think a patch is a bit big at around 200 lines, but for the specific case of "here is a new device" bigger than that is OK, because it's just adding new files rather than merging changes into existing ones.

https://www.qemu.org/docs/master/devel/submitting-a-patch.html
has some other advice on patch submission, if you haven't read that yet.

thanks
-- PMM

#7 lore raw
Quoted 17 lines · Sergey
Quoted 1 line

Could you please tell me what size is appropriate for a single patch?

The most important things for patch splitting are:
 * everything still has to compile cleanly
 * the contents of a single patch should be a coherent single thing that it makes sense to review in one part

If there's something in there that only touches 20 lines of code but is a coherent single change, it's fine to have that in its own patch -- small patches are easy to review.

At the upper end, I tend to think a patch is a bit big at around 200 lines, but for the specific case of "here is a new device" bigger than that is OK, because it's just adding new files rather than merging changes into existing ones.

Quoted 3 lines

https://www.qemu.org/docs/master/devel/submitting-a-patch.html <https://www.qemu.org/docs/master/devel/submitting-a-patch.html>
has some other advice on patch submission, if you haven't
read that yet.

FWIW example of series adding the Pi Zero:

https://lore.kernel.org/qemu-devel/[email protected]/

#8 lore raw

Thanks for the example, Phillipe! It's helpful!

________________________________
От: Philippe Mathieu-Daudé <[email protected]> Отправлено: 22 мая 2023 г. 16:41:53
Кому: Sergey Kambalin; Kambalin, Sergey
Копия: Peter Maydell; [email protected]; [email protected] Тема: Re: [PATCH] [rpi4b] Make bootable rpi4b model

Quoted 17 lines · Sergey
Quoted 1 line

Could you please tell me what size is appropriate for a single patch?

The most important things for patch splitting are:
* everything still has to compile cleanly
* the contents of a single patch should be a coherent single thing that it makes sense to review in one part

If there's something in there that only touches 20 lines of code but is a coherent single change, it's fine to have that in its own patch -- small patches are easy to review.

At the upper end, I tend to think a patch is a bit big at around 200 lines, but for the specific case of "here is a new device" bigger than that is OK, because it's just adding new files rather than merging changes into existing ones.

Quoted 4 lines

https://www.qemu.org/docs/master/devel/submitting-a-patch.html
<https://www.qemu.org/docs/master/devel/submitting-a-patch.html>
has some other advice on patch submission, if you haven't read that yet.

FWIW example of series adding the Pi Zero:

https://lore.kernel.org/qemu-devel/[email protected]/